﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Code.Models;
using QianBuo.Lottery.Web.Models;
using Code.Commen;
using System.Web.Mvc;
using Code.BLL;

namespace QianBuo.Lottery.Web.Areas.Manage.Models.Site
{
    [Serializable]
    public class OptionModel
    {
        public ModelNameValue<Option_Site_Key, NameValueItem<string, string>> Options { get; set; }
        public ModelNameValue<Option_Site_Key, NameValueItem<string, string>> OldOptions { get; set; }
    }
    public static class OptionEx
    {
        public static string GetJQueryValidate(this Option_Site_Key key, string validateStr)
        {
            switch (key)
            {

                case Option_Site_Key.Site_Notice_HomeCount:
                    return "{number:true,min:1," + validateStr + "}";
                case Option_Site_Key.User_MaxTakeMoneyCount:
                case Option_Site_Key.User_MinTakeMoney:
                case Option_Site_Key.User_MaxChaseTaskMun:
                case Option_Site_Key.Site_MailServer_Port:
                    return "{digits:true,min:0," + validateStr + "}";
                case Option_Site_Key.Site_Lottery_MinWinMoneyRatio:
                case Option_Site_Key.Site_Lottery_MaxBackWinMoneyMarginRatio:
                case Option_Site_Key.Site_Lottery_MaxBackMoneyMarginRatio:
                case Option_Site_Key.Site_Lottery_MinBackMoneyRatio:
                case Option_Site_Key.Site_Lottery_Member_MaxBackMoneyRatio:
                case Option_Site_Key.Site_Lottery_MinBackMoneyMarginRatio:
                case Option_Site_Key.Site_Lottery_MinBackWinMoneyMarginRatio:
                    return "{number:true,min:0,max:100," + validateStr + "}";
                case Option_Site_Key.Site_Cache_OptionsTime:
                case Option_Site_Key.Site_Cache_LotteryTime:
                case Option_Site_Key.Site_Cache_PlayListTime:
                case Option_Site_Key.Site_Cache_PlayTypeTime:
                case Option_Site_Key.Site_Cache_RatioTime:
                case Option_Site_Key.Site_Cache_WinModelTime:
                case Option_Site_Key.Site_Cache_AuthenticationTime:
                case Option_Site_Key.Site_Cache_NoticeTime:
                case Option_Site_Key.Site_Lottery_OutBill_Delay:
                case Option_Site_Key.Site_AddMoney_Min:
                    return "{number:true,min:0," + validateStr + "}";
                case Option_Site_Key.Site_Service_TakeMoneyStartTime:
                case Option_Site_Key.Site_Service_TakeMoneyEndTime:
                    return @"{regex:'\\d{1,2}:\\d{1,2}',messages:{regex:'格式不正确'}," + validateStr + "}";
                default:
                    return "{" + validateStr + "}";
            }
        }
    }

    [Serializable]
    public class OptionHtmlModel
    {
        public Option_Site_Key Key { get; set; }
        public string Value { get; set; }
    }

    [Serializable]
    public class SetBackMoneyRatioModel
    {
        public BackMoneyRatioModel[] Options { get; set; }
    }
    [Serializable]
    public class ClearDataModel
    {
        [Required(ErrorMessage = "*")]
        public DateTime? Date { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
    }

    [Serializable]
    public class PayOptionModel
    {
        public ModelNameValue<PayType, PayOptionItem> Pays { get; set; }
    }

    [Serializable]
    public class PayOptionItem
    {
        public PayType Pay { get; set; }
        public string Name { get; set; }
        public string MemberID { get; set; }
        public bool Enable { get; set; }
    }

    [Serializable]
    public class YeePayModel
    {
        public string Name { get; set; }
        public string MemberID { get; set; }
        public string Key { get; set; }
        public bool? Enable { get; set; }
        public string Addr { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
    }

    [Serializable]
    public class TenPayModel
    {
        public string Name { get; set; }
        public string MemberID { get; set; }
        public string Key { get; set; }
        public bool? Enable { get; set; }
        public string Addr { get; set; }
        public string MemberName { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
    }

    [Serializable]
    public class AliPayModel
    {
        public string Name { get; set; }
        public string MemberID { get; set; }
        public string MemberName { get; set; }
        public string Key { get; set; }
        public bool? Enable { get; set; }
        public string Addr { get; set; }
        /// <summary>
        /// 支付宝账号
        /// </summary>
        public string Email { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
    }

    [Serializable]
    public class ICBC_ManualModel
    {
        public string Name { get; set; }
        public string MemberName { get; set; }
        public string MemberID { get; set; }
        public bool? Enable { get; set; }
        public string Memo { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
        [Range(0d, 100d, ErrorMessage = "输入百分比")]
        public double? ChargeRatio { get; set; }

        public double? MinCharge { get; set; }
        public double? MaxCharge { get; set; }

        public string AliPayMemberName { get; set; }
        public string AliPayMemberID { get; set; }
        public string TenPayMemberName { get; set; }
        public string TenPayMemberID { get; set; }
    }


    [Serializable]
    public class TenPays_ManualModel
    {
        public string Name { get; set; }
        public string MemberName { get; set; }
        public string MemberID { get; set; }
        public bool? Enable { get; set; }
        public string Memo { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
        [Range(0d, 100d, ErrorMessage = "输入百分比")]
        public double? ChargeRatio { get; set; }

        public double? MinCharge { get; set; }
        public double? MaxCharge { get; set; }

        public string AliPayMemberName { get; set; }
        public string AliPayMemberID { get; set; }
        public string TenPayMemberName { get; set; }
        public string TenPayMemberID { get; set; }
    }

    [Serializable]
    public class Alipays_ManualModel
    {
        public string Name { get; set; }
        public string MemberName { get; set; }
        public string MemberID { get; set; }
        public bool? Enable { get; set; }
        public string Memo { get; set; }
        [Required(ErrorMessage = "*")]
        public string Pwd { get; set; }
        [Range(0d, 100d, ErrorMessage = "输入百分比")]
        public double? ChargeRatio { get; set; }

        public double? MinCharge { get; set; }
        public double? MaxCharge { get; set; }

        public string AliPayMemberName { get; set; }
        public string AliPayMemberID { get; set; }
        public string TenPayMemberName { get; set; }
        public string TenPayMemberID { get; set; }
    }
    [Serializable]
    public class ConsumptionModel
    {
        public RatioItem[] Ratios { get; set; }
        public WinModelItem[] WinModels { get; set; }
    }

    [Serializable]
    public class RatioItem
    {
        public int ID { get; set; }
        [Required(ErrorMessage = "*")]
        public string Name { get; set; }
        public bool Enable { get; set; }
        [Range(0.0001, 9999, ErrorMessage = "0-1之间")]
        public double RadixMoney { get; set; }
        [Required(ErrorMessage = "*")]
        public double BackMoneyDifference { get; set; }
    }

    [Serializable]
    public class WinModelItem
    {
        public int ID { get; set; }
        public bool Enable { get; set; }
        [Required(ErrorMessage = "*")]
        public string Name { get; set; }
    }

    [Serializable]
    public class NoticeModel
    {
        public NoticeModel()
        {
            Serch = new NoticeSerchModel();
        }
        public NoticeItem[] Notices { get; set; }
        public IList<SelectListItem> States { get; set; }
        public NoticeSerchModel Serch { get; set; }
        public int SumCount { get; set; }
        public int PageSize { get; set; }
        public int Page { get; set; }
    }

    [Serializable]
    public class NoticeSerchModel
    {
        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }
        public NoticeState? State { get; set; }
        public string Title { get; set; }
    }

    [Serializable]
    public class EditNoticModel
    {
        public bool Continue { get; set; }
        public bool IsNew { get; set; }
        public NoticeItem Item { get; set; }
        public ModelNameValue<NoticeState, string> States { get; set; }
    }

    [Serializable]
    public class NoticeItem
    {
        [Required]
        public long ID { get; set; }
        public DateTime AddTime { get; set; }
        [Required]
        public string Title { get; set; }
        public string Message { get; set; }
        [Required]
        public NoticeState State { get; set; }
        /// <summary>
        /// 高亮
        /// </summary>
        [Required]
        public bool HighLight { get; set; }
    }


    [Serializable]
    public class LoginLogModel
    {
        public int Page { get; set; }
        public int PageSize { get; set; }
        public int SumCount { get; set; }
        public LoginLogSerchModel Serch { get; set; }
        public IEnumerable<SelectListItem> Types { get; set; }
        public IEnumerable<SelectListItem> Results { get; set; }
        public IEnumerable<LoginLog_V> Logs { get; set; }
    }

    [Serializable]
    public class LoginLogSerchModel
    {
        public string LoginName { get; set; }
        public LoginLogType? Type { get; set; }
        public LoginResult? Result { get; set; }
        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }
        public string LoginIP { get; set; }
    }
}